package com.xingkeduo.business.order.remote;

import com.alibaba.fastjson.JSON;
import com.xingkeduo.business.order.remote.feign.MessageFeignService;
import com.xingkeduo.dto.*;
import com.xingkeduo.pojo.enums.OrderSource;
import com.xingkeduo.pojo.enums.PayType;
import com.xingkeduo.pojo.table.Order;
import com.xingkeduo.util.pojo.exception.BusinessException;
import com.xingkeduo.utils.ResponseUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;

import static com.xingkeduo.utils.DateTimeUtils.yyyy_MM_dd_HH_mm_ss;

/**
 * @author chi  2019-05-24 11:24
 **/
@Component
@Slf4j
public class MessagePushService {

    @Resource
    private MessageFeignService messageFeignService;
    @Resource
    private UserRemoteService userRemoteService;

    //公众号mpid
    private static final String MPID = "xingkeduozhengshi";
    //小程序mpid
    private static final String MINI_MPID = "wx9b65e35c7d64de0c";

    //支付成功模板
    private static final String PAY_SUCCESS_TYPE = "RM15VWsC2paC_ocv856rfFIDVkAg4JlkYFYvvBgIr8U";

    //服务进度提醒
    private static final String SERVICE_PROGRESS_TYPE = "bZnZAXyZIXeMHySw99MfpeMOProDx-o3L0GYJFHnfD0";

    //服务评价
    private static final String SERVICE_EVALUATION_TYPE = "qdx6tQqGUaOxLO1RRvU6st3Llb6izN7cFe3ysmFLf4c";


    //排队过号提醒
    private static final String QUEUE_NUMBER_NUMBER_TYPE = "LO6U6plFLOl51fkWnhJyudSwUUr5xhdhS3zxU8J-oEo";

    //预约变更通知
    private static final String APPOINTMENT_CHANGE_TYPE = "XpQnr82P8ivWbjualTAwCxgAO03j7ioURSvjgJQnJsw";

    //预约变更通知
    private static final String ORDER_INDEMNITY_TYPE = "wnJWCzFonpkkjj-maRykGhO8mdSym2_pn65XE8QXV2M";

    /**
     * 订单支付成功通知
     * order.getUserId()                    用户ID
     * order.getUserNickName()              用户微信昵称
     * order.getStoreName()                 店铺名字
     * order.getOrderNo()                   订单号
     * order.getPayPrice()                  支付金额
     * order.getPayTime()                   支付时间
     * order.getWaitingLineNo()             排队号
     * order.getAdminNickName()      预约发型师
     * order.getServiceTypeName()           服务名称
     * order.getAppointmentStartTime()      预约服务时间
     * @return
     */

    public boolean pushPaySuccessMessage(Order order) {

        try {
            log.info("订单支付成功通知 order:{}", order);

            if(OrderSource.SUI_XING_FU.equals(order.getOrderSource())){
                return false;
            }

            Optional<UserRemoteDto> byUserId = userRemoteService.getByUserId(order.getUserId());
            if(!byUserId.isPresent()){
                return false;
            }
            UserRemoteDto userRemoteDto = byUserId.get();
            log.info("userRemote:{}", JSON.toJSONString(userRemoteDto));

            PayType payType = order.messageChannel();
            log.info("订单支付成功通知 payType:{}", payType);
            if(PayType.WECHAT.equals(payType)){

                List<TemplateData> data = new ArrayList<>();
                data.add(new TemplateData("first", "hi，"+order.getUserNickName() +"，感谢您的光临:\n"));
                data.add(new TemplateData("keyword1", order.getStoreName()));
                data.add(new TemplateData("keyword2", order.getOrderNo()));
                data.add(new TemplateData("keyword3", order.getPayPrice()+ "元") );
                data.add(new TemplateData("keyword4", yyyy_MM_dd_HH_mm_ss.format(order.getPayTime())));

                String remark = "您的排队号："+ order.getWaitingLineNo()+
                        "\n预约发型师：" + order.getAdminNickName() +
                        "\n服务名称：" + order.getServiceTypeName() +
                        "\n预约服务时间："+yyyy_MM_dd_HH_mm_ss.format(order.getAppointmentStartTime()) +
                        "\n\n轮到您服务时，请展示此票给发型师，您需要提前到店哦，若您迟到，将会被过号(•͈˽•͈)";

                data.add(new TemplateData("remark", remark));
                String url = "https://m.xingkeduo.com/react/order/detail?f_user_id="+order.getUserId()+"&order_no="+order.getOrderNo()+"&store_id="+order.getStoreId()+"&f_store_id="+order.getStoreId()+"&is_new_system=2"; //跳转链接

                TemplateDTO templateDTO = TemplateDTO.builder()
                        .type(PAY_SUCCESS_TYPE)
                        .url(url)
                        .data(data)
                        .userId(order.getUserId())
//                        .pagePath(pagePath)
//                        .miniProgramId(MINI_MPID)
                        .build();
                templateDTO.setMpId(MPID);
                templateDTO.setOpenId(userRemoteDto.getGzhOpenId());
                log.info("微信消息发送 templateDTO:{}", JSON.toJSONString(templateDTO));
                String s = messageFeignService.pushMessage(SendingTypeEnum.TEMPLATE.value(), JSON.toJSONString(templateDTO));
                log.info("微信消息发送返回值 s:{}", s);

            }else {
                log.info("支付宝支付宝支付宝:{}", order.messageChannel());
                List<TemplateData> data = new ArrayList<>();
                data.add(new TemplateData("first", "hi，"+order.getUserNickName() +"，感谢您的光临:"));
                data.add(new TemplateData("keyword1", order.getStoreName()));
                data.add(new TemplateData("keyword2", order.getPayPrice()+ "元"));
                data.add(new TemplateData("keyword3", order.getOrderNo()) );
                data.add(new TemplateData("keyword4", yyyy_MM_dd_HH_mm_ss.format(order.getPayTime())));

                String remark = "您的排队号："+ order.getWaitingLineNo()+
                        "\n预约发型师：" + order.getAdminNickName() +
                        "\n服务名称：" + order.getServiceTypeName() +
                        "\n预约服务时间："+yyyy_MM_dd_HH_mm_ss.format(order.getAppointmentStartTime()) +
                        "\n\n轮到您服务时，请展示此票给发型师，您需要提前到店哦，若您迟到，将会被过号(•͈˽•͈)";

                data.add(new TemplateData("remark", remark));
                AlipayTemplateDTO alipayTemplateDTO = AlipayTemplateDTO.builder()
                        .userId(userRemoteDto.getAliUserId())
                        .url("https://m.xingkeduo.com/react/order/detail?f_user_id="+order.getUserId()+"&order_no="+order.getOrderNo()+"&store_id="+order.getStoreId()+"&f_store_id="+order.getStoreId()+"&is_new_system=2")//跳转链接
                        .action_name("立即查看")
                        .dataList(data)
                        .headColor("#85be53")
                        .templateId("24eae3eff4a941f1960a324f0ca59e65") //支付宝模板id
                        .build();
                log.info("支付宝消息发送 alipayTemplateDTO:{}", JSON.toJSONString(alipayTemplateDTO));
                ResponseUtils<Boolean> booleanResponseUtils = messageFeignService.pushAlipayMessage(alipayTemplateDTO);
                log.info("支付宝消息发送返回值 booleanResponseUtils:{}", JSON.toJSONString(booleanResponseUtils));

            }
        } catch (Exception e) {
            log.error("pushPaySuccessMessage:{}",e);
        }

        return true;
    }

    /**
     * 服务进度提醒
     * order.getOrderNo()               订单号
     * order.getUserId()                用户ID
     * order.getUserNickName()          用户微信昵称
     * order.getServiceTypeName()       服务类型名称
     * order.getAdminNickName()  预约发型师名称
     * @return
     */
    public boolean pushServiceProgressMessage(Order order){
        try {
            log.info("pushServiceProgressMessage:{}", order.getOrderNo());
            UserRemoteDto userRemoteDto = userRemoteService.getByUserId(order.getUserId()).orElseThrow(() -> new BusinessException(BusinessException.Type.DEFAULT, "用户不存在"));

            PayType payType = order.messageChannel();
            if(PayType.WECHAT.equals(payType)){
            List<TemplateData> data = new ArrayList<>();
            data.add(new TemplateData("first", "hi，"+order.getUserNickName() +"，距您预约剪发时间还有20分钟:\n"));
            data.add(new TemplateData("keyword1", order.getServiceTypeName()));
            data.add(new TemplateData("keyword2", "即将开始"));
            data.add(new TemplateData("keyword3", order.getAdminNickName()));
            String remark = "\n若您已到店，请稍作等候哦(•͈˽•͈)";

            data.add(new TemplateData("remark", remark));
            String url = "https://m.xingkeduo.com/react/order/detail?f_user_id="+order.getUserId()+"&order_no="+order.getOrderNo()+"&store_id="+order.getStoreId()+"&f_store_id="+order.getStoreId()+"&is_new_system=2"; //跳转链接;


            TemplateDTO templateDTO = TemplateDTO.builder()
                    .type(SERVICE_PROGRESS_TYPE)
                    .url(url)
                    .data(data)
                    .userId(order.getUserId())
//                    .pagePath(pagePath)
//                    .miniProgramId(MINI_MPID)
                    .build();
            templateDTO.setMpId(MPID);
            templateDTO.setOpenId(userRemoteDto.getGzhOpenId());

            messageFeignService.pushMessage(SendingTypeEnum.TEMPLATE.value(), JSON.toJSONString(templateDTO));
            }else {
                //支付宝服务状态提醒
                List<TemplateData> data = new ArrayList<>();
                data.add(new TemplateData("first", "hi，"+order.getUserNickName() +"，距您预约剪发时间还有20分钟:"));
                data.add(new TemplateData("keyword1", order.getServiceTypeName()));
                data.add(new TemplateData("keyword2", "即将开始"));

                String remark = "若您已到店，请稍作等候哦(•͈˽•͈)";

                data.add(new TemplateData("remark", remark));

                AlipayTemplateDTO alipayTemplateDTO = AlipayTemplateDTO.builder()
                        .userId(userRemoteDto.getAliUserId())
                        .url( "https://m.xingkeduo.com/react/order/detail?f_user_id="+order.getUserId()+"&order_no="+order.getOrderNo()+"&store_id="+order.getStoreId()+"&f_store_id="+order.getStoreId()+"&is_new_system=2")//跳转链接
                        .action_name("立即查看")
                        .dataList(data)
                        .headColor("#85be53")
                        .templateId("0aa4c24b0f6f430c89f0d2c9df827d63") //支付宝模板id
                        .build();

                messageFeignService.pushAlipayMessage(alipayTemplateDTO);
            }
        } catch (Exception e) {
            log.error("pushServiceProgressMessage:{}",e);
        }
        return true;
    }

    /**
     * 订单评价提醒
     * @param order
     * @return
     */
    public boolean pushServiceEvaluationMessage(Order order) {

        try {
            log.info("pushServiceEvaluationMessage:{}", order.getOrderNo());
            UserRemoteDto userRemoteDto = userRemoteService.getByUserId(order.getUserId()).orElseThrow(() -> new BusinessException(BusinessException.Type.DEFAULT, "用户不存在"));

            PayType payType = order.messageChannel();
            if(PayType.WECHAT.equals(payType)){

                List<TemplateData> data = new ArrayList<>();
                data.add(new TemplateData("first", "hi，"+order.getUserNickName()+":\n"));
                data.add(new TemplateData("keyword1", order.getAdminNickName()));
                data.add(new TemplateData("keyword2", order.getServiceTypeName()));

                String remark = "\n感谢您体验星客多专业剪发服务，为了向您提供更好的服务，欢迎点击详情对我们的服务作出评价(•͈˽•͈))";

                data.add(new TemplateData("remark", remark));
                String url = "https://m.xingkeduo.com/react/user/new_comment?f_user_id="+order.getUserId()+"&order_no="+order.getOrderNo()+"&store_id="+order.getStoreId()+"&is_new_system=2"; //跳转链接

                TemplateDTO templateDTO = TemplateDTO.builder()
                        .type(SERVICE_EVALUATION_TYPE)
                        .url(url)
                        .data(data)
                        .userId(order.getUserId())
//                        .pagePath(pagePath)
//                        .miniProgramId(MINI_MPID)
                        .build();
                templateDTO.setMpId(MPID);
                templateDTO.setOpenId(userRemoteDto.getGzhOpenId());

                messageFeignService.pushMessage(SendingTypeEnum.TEMPLATE.value(), JSON.toJSONString(templateDTO));
            }else {
                //支付宝订单评价提醒
                List<TemplateData> data = new ArrayList<>();
                data.add(new TemplateData("first", "hi，"+order.getUserNickName() +":"));
                data.add(new TemplateData("keyword1", order.getOrderNo()));
                data.add(new TemplateData("keyword2", order.getPayPrice()+ "元"));

                String remark = "感谢您体验星客多专业剪发服务，为了向您提供更好的服务，欢迎点击详情对我们的服务作出评价(•͈˽•͈))";

                data.add(new TemplateData("remark", remark));

                AlipayTemplateDTO alipayTemplateDTO = AlipayTemplateDTO.builder()
                        .userId(userRemoteDto.getAliUserId())
                        .url("https://m.xingkeduo.com/react/user/new_comment?f_user_id="+order.getUserId()+"&order_no="+order.getOrderNo()+"&store_id="+order.getStoreId()+"&is_new_system=2")//跳转链接
                        .action_name("立即查看")
                        .dataList(data)
                        .headColor("#85be53")
                        .templateId("5fd17892c6444712b7f3ab6aabf8bf59") //支付宝模板id
                        .build();

                messageFeignService.pushAlipayMessage(alipayTemplateDTO);

            }
        } catch (Exception e) {
            log.error("pushServiceEvaluationMessage:{}",e);
        }

        return true;
    }

    /**
     * 排队过号提醒
     * order.getOrderNo()               订单号
     * order.getUserId()                用户ID
     * order.getUserNickName()          用户微信昵称
     *  order.getStoreName()            店铺名称
     * order.getWaitingLineNo()         排队号
     * order.getTicketCode()            验票码
     * order.getAppointmentStartTime()  预约开始时间
     * @return
     */
    public boolean pushQueueNumberMessage(Order order){
        try {
            log.info("pushQueueNumberMessage:{}", order.getOrderNo());
            UserRemoteDto userRemoteDto = userRemoteService.getByUserId(order.getUserId()).orElseThrow(() -> new BusinessException(BusinessException.Type.DEFAULT, "用户不存在"));

            PayType payType = order.messageChannel();
            if(PayType.WECHAT.equals(payType)){
            List<TemplateData> data = new ArrayList<>();
            data.add(new TemplateData("first", "尊敬的"+order.getUserNickName() +"你好:\n"));
            data.add(new TemplateData("keyword1", order.getStoreName()));
            data.add(new TemplateData("keyword2", order.getOrderNo()));
            data.add(new TemplateData("keyword3", order.getWaitingLineNo()));
            data.add(new TemplateData("keyword4", order.getTicketCode()));
            data.add(new TemplateData("keyword5", yyyy_MM_dd_HH_mm_ss.format(order.getAppointmentStartTime())+"\n"));

            String remark = "由于您未及时赶到，您的预约已自动过号\n" +
                    "\n" +
                    "请点击详情重新预约";

            data.add(new TemplateData("remark", remark));
            String url = "https://m.xingkeduo.com/react/order/detail?f_user_id="+order.getUserId()+"&order_no="+order.getOrderNo()+"&store_id="+order.getStoreId()+"&f_store_id="+order.getStoreId()+"&is_new_system=2"; //跳转链接


            TemplateDTO templateDTO = TemplateDTO.builder()
                    .type(QUEUE_NUMBER_NUMBER_TYPE)
                    .url(url)
                    .data(data)
                    .userId(order.getUserId())
//                    .pagePath(pagePath)
//                    .miniProgramId(MINI_MPID)
                    .build();
            templateDTO.setMpId(MPID);
            templateDTO.setOpenId(userRemoteDto.getGzhOpenId());

            messageFeignService.pushMessage(SendingTypeEnum.TEMPLATE.value(), JSON.toJSONString(templateDTO));
            }else {
                //支付宝排队过号提醒
                List<TemplateData> data = new ArrayList<>();
                data.add(new TemplateData("first", "尊敬的"+order.getUserNickName() +"您好:"));
                data.add(new TemplateData("keyword1", order.getStoreName()));
                data.add(new TemplateData("keyword2", order.getOrderNo()));
                data.add(new TemplateData("keyword3", order.getWaitingLineNo()));
                data.add(new TemplateData("keyword4", order.getTicketCode()));
                data.add(new TemplateData("keyword5", yyyy_MM_dd_HH_mm_ss.format(order.getAppointmentStartTime())));

                String remark = "由于您未及时赶到，您的预约已自动过号\n" +
                        "\n请点击详情重新预约";

                data.add(new TemplateData("remark", remark));

                AlipayTemplateDTO alipayTemplateDTO = AlipayTemplateDTO.builder()
                        .userId(userRemoteDto.getAliUserId())
                        .url("https://m.xingkeduo.com/react/order/detail?f_user_id="+order.getUserId()+"&order_no="+order.getOrderNo()+"&store_id="+order.getStoreId()+"&f_store_id="+order.getStoreId()+"&is_new_system=2")//跳转链接
                        .action_name("立即查看")
                        .dataList(data)
                        .headColor("#85be53")
                        .templateId("6f79c71de4ab4e02a188cf8472229f15") //支付宝模板id
                        .build();

                messageFeignService.pushAlipayMessage(alipayTemplateDTO);

            }
        } catch (Exception e) {
            log.error("pushQueueNumberMessage:{}",e);
        }
        return true;
    }

    /**
     * 预约变更提醒
     * order.getUserId()                    用户ID
     * order.getUserNickName()              用户微信昵称
     * order.getStoreName()                 店铺名字
     * order.getOrderNo()                   订单号
     * order.getPayPrice()                  支付金额
     * order.getPayTime()                   支付时间
     * order.getWaitingLineNo()             排队号
     * order.getAdminNickName()      预约发型师
     * order.getServiceTypeName()           服务名称
     * order.getAppointmentStartTime()      预约服务时间
     * @return
     */
    public boolean pushAppointmentChangeMessage(Order order){
        try {
            log.info("pushAppointmentChangeMessage:{}", order.getOrderNo());
            UserRemoteDto userRemoteDto = userRemoteService.getByUserId(order.getUserId()).orElseThrow(() -> new BusinessException(BusinessException.Type.DEFAULT, "用户不存在"));

            PayType payType = order.messageChannel();
            if(PayType.WECHAT.equals(payType)){
            List<TemplateData> data = new ArrayList<>();
            data.add(new TemplateData("first", "hi，"+order.getUserNickName() +":\n"));
            data.add(new TemplateData("keyword1", order.getOrderNo()));
            data.add(new TemplateData("keyword2", order.getServiceTypeName()));
            data.add(new TemplateData("keyword3", "重新预约"));
            String adminNickName =  order.getAdminNickName();
            String remark = "您的排队号："+ order.getWaitingLineNo()+
                    "\n预约发型师：" + adminNickName +
//                    "\n服务名称：" + order.getServiceTypeName() +
                    "\n预约服务时间："+yyyy_MM_dd_HH_mm_ss.format(order.getAppointmentStartTime()) +
                    "\n\n您已重新预约成功，轮到您服务时，请展示此票给发型师，您需要提前到店哦，若您迟到，将会被过号(•͈˽•͈))";

            data.add(new TemplateData("remark", remark));
            String url = "https://m.xingkeduo.com/react/order/detail?f_user_id="+order.getUserId()+"&order_no="+order.getOrderNo()+"&store_id="+order.getStoreId()+"&f_store_id="+order.getStoreId()+"&is_new_system=2"; //跳转链接


            TemplateDTO templateDTO = TemplateDTO.builder()
                    .type(APPOINTMENT_CHANGE_TYPE)
                    .url(url)
                    .data(data)
                    .userId(order.getUserId())
//                    .pagePath(pagePath)
//                    .miniProgramId(MINI_MPID)
                    .build();
            templateDTO.setMpId(MPID);
            templateDTO.setOpenId(userRemoteDto.getGzhOpenId());

            messageFeignService.pushMessage(SendingTypeEnum.TEMPLATE.value(), JSON.toJSONString(templateDTO));
            }else {
                //支付宝预约提醒
                List<TemplateData> data = new ArrayList<>();
                data.add(new TemplateData("first", "hi，"+order.getUserNickName() +":"));
                data.add(new TemplateData("keyword1", yyyy_MM_dd_HH_mm_ss.format(order.getAppointmentStartTime())));
                data.add(new TemplateData("keyword2", order.getServiceTypeName()));
                data.add(new TemplateData("keyword3", order.getOrderNo()));
                String adminNickName =  order.getAdminNickName();
                String remark = "您的排队号："+ order.getWaitingLineNo()+
                        "\n预约发型师：" + adminNickName +
                        "\n\n您已重新预约成功，轮到您服务时，请展示此票给发型师，您需要提前到店哦，若您迟到，将会被过号(•͈˽•͈))";

                data.add(new TemplateData("remark", remark));

                AlipayTemplateDTO alipayTemplateDTO = AlipayTemplateDTO.builder()
                        .userId(userRemoteDto.getAliUserId())
                        .url("https://m.xingkeduo.com/react/order/detail?f_user_id="+order.getUserId()+"&order_no="+order.getOrderNo()+"&store_id="+order.getStoreId()+"&f_store_id="+order.getStoreId()+"&is_new_system=2")//跳转链接
                        .action_name("立即查看")
                        .dataList(data)
                        .headColor("#85be53")
                        .templateId("8112657c1c5141f1ae3df04ea84d16cc") //支付宝模板id
                        .build();

                messageFeignService.pushAlipayMessage(alipayTemplateDTO);
            }
        } catch (Exception e) {
            log.error("pushAppointmentChangeMessage:{}",e);
        }
        return true;
    }

    /**
     * 订单赔偿通知
     * order.getUserId()                    用户ID
     * order.getUserNickName()              用户微信昵称
     * order.getOrderNo()                   订单号
     * couponName                           推送优惠券吗名称
     * couponUseEvaluation                  优惠券使用有效期，如(2019.08.01-2019.09.01)
     * @return
     */

    public boolean pushOrderIndemnityMessage(Order order, String couponName ,String couponUseEvaluation){
        try {
            log.info("pushOrderIndemnityMessage:{}", order.getOrderNo(),couponName);
            UserRemoteDto userRemoteDto = userRemoteService.getByUserId(order.getUserId()).orElseThrow(() -> new BusinessException(BusinessException.Type.DEFAULT, "用户不存在"));

            PayType payType = order.messageChannel();

            if(PayType.WECHAT.equals(payType)){
            List<TemplateData> data = new ArrayList<>();
            data.add(new TemplateData("first", "尊敬的"+order.getUserNickName() +"你好，非常抱歉未能在预约时间为您提供剪发服务，让您久等了，"+couponName+"已发送到您的账户(•͈˽•͈)\n"));
            data.add(new TemplateData("keyword1", order.getOrderNo()));
            data.add(new TemplateData("keyword2", "服务晚点"));
            data.add(new TemplateData("keyword3", couponName));

            String remark = "\n感谢您的理解和支持，我们会不断努力优化预约系统为您提供更精准的剪发时间 (•̀ᴗ•́)و";

            data.add(new TemplateData("remark", remark));
            String url = "https://m.xingkeduo.com/react/user/coupon_list?f_user_id="+order.getUserId()+"&is_new_system=2"; //跳转链接


            TemplateDTO templateDTO = TemplateDTO.builder()
                    .type(ORDER_INDEMNITY_TYPE)
                    .url(url)
                    .data(data)
                    .userId(order.getUserId())
//                    .pagePath(pagePath)
//                    .miniProgramId(MINI_MPID)
                    .build();
            templateDTO.setMpId(MPID);
            templateDTO.setOpenId(userRemoteDto.getGzhOpenId());

            messageFeignService.pushMessage(SendingTypeEnum.TEMPLATE.value(), JSON.toJSONString(templateDTO));
            }else {
                //支付宝订单赔偿通知
                List<TemplateData> data = new ArrayList<>();
                data.add(new TemplateData("first", "尊敬的"+order.getUserNickName() +"你好，非常抱歉未能在预约时间为您提供剪发服务，让您久等了，"+couponName+"已发送到您的账户(•͈˽•͈)"));
                data.add(new TemplateData("keyword1", couponName));
                data.add(new TemplateData("keyword2", couponUseEvaluation));

                String remark = "\n\n感谢您的理解和支持，我们会不断努力优化预约系统为您提供更精准的剪发时间 (•̀ᴗ•́)و";

                data.add(new TemplateData("remark", remark));

                AlipayTemplateDTO alipayTemplateDTO = AlipayTemplateDTO.builder()
                        .userId(userRemoteDto.getAliUserId())
                        .url("https://m.xingkeduo.com/react/user/coupon_list?f_user_id="+order.getUserId()+"&is_new_system=2")//跳转链接
                        .action_name("立即查看")
                        .dataList(data)
                        .headColor("#85be53")
                        .templateId("2e6e7b190be2455591c18810e47bb2a9") //支付宝模板id
                        .build();

                messageFeignService.pushAlipayMessage(alipayTemplateDTO);
            }
        } catch (Exception e) {
            log.error("pushOrderIndemnityMessage:{}",e);
        }
        return true;
    }
}